// models/user.go

package models

import (
	"time"

	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)

const (
	UserGenderMale   = "m"
	UserGenderFemale = "f"
)

// model结构
type User struct {
	ID         bson.ObjectId `bson:"_id,omitempty"`
	Username   string
	Password   string
	Salt       string
	Nickname   string
	Gender     string
	Mobile     string    `bson:",omitempty"`
	CreateTime time.Time `bson:"create_time"`
	UpdateTime time.Time `bson:"update_time,omitempty"`
}

// model表
type UserColl struct {
	*mgo.Collection
}

// 新建表对象，用于访问表
func NewUserColl() (uc *UserColl, err error) {
	// 创建表访问对象通过NewMongodbColl这个函数，详见models/common.go文件
	coll, err := NewMongodbColl("zqc", "zqc", "user")
	if err != nil {
		return nil, err
	}
	return &UserColl{
		Collection: coll,
	}, nil
}
